package com.example.demo.t2;

import java.util.Iterator;
import java.util.List;

public class T2_2<T> implements Iterable<T> {

    private final List<T> list;

    public T2_2(List<T> list) {
        this.list = list;
    }

    @Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            @Override
            public boolean hasNext() {
                return true;
            }

            @Override
            public T next() {
                return list.get((int)(list.size() * Math.random()));
            }
        };
    }
}
